package com.chenjiagou.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/admin")
public class AdminHomeController {

    @GetMapping("/home")
    public String adminHome(HttpSession session, Model model) {
        Integer role = (Integer) session.getAttribute("role");
        if (role == null || role != 1) {
            return "redirect:/login";
        }

        return "adminhome"; // 返回模板名
    }
}
